using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using NBusiness.CodeDom;
using NBusiness.CodeDom.Compiler;

namespace NBusiness.Templates
{
    public class TemplateWarning : Warning
    {
        private ITemplate _template;
        public ITemplate Template
        {
            get { return _template; }
        }
        private System.Reflection.MethodInfo _method;
        public System.Reflection.MethodInfo Method
        {
            get { return _method; }
        }
        
        public TemplateWarning(ITemplate template, System.Reflection.MethodInfo method, string message, EntityElement element)
            : base("", message, element)
        {
            if (template == null)
                throw new ArgumentNullException("template cannot be null");

            if (message == null)
                throw new ArgumentNullException("message cannot be null");

            _template = template;
            _method = method;
        }

        public override string ToString()
        {
            return string.Format("{0} in {1}, {2}",
                Message,
                Template.GetType().Name,
                (Method!=null ? Method.Name : "unknown"));
        }
    }
}
